
class FooInterface {
public:
    virtual ~FooInterface() {}

    virtual std::string getArbitraryString() = 0;

    virtual int getPosition() = 0;
};

class MockFoo : public FooInterface {
public:
    MOCK_METHOD0(getArbitraryString, std::string()
    );
    MOCK_METHOD0(getPosition,
    int());
};

using namespace seamless;
using namespace std;
using ::testing::Return;

int main(int argc, char **argv) {
    ::testing::InitGoogleMock(&argc, argv);
    int n = 100;
    string value = "Hello World!";

    MockFoo mockFoo;
    EXPECT_CALL(mockFoo, getArbitraryString())
            .Times(1)
            .WillOnce(Return(value));
    string returnValue = mockFoo.getArbitraryString();

    cout << "Returned Value: " << returnValue
         << endl; //在这里Times(2)意思是调用两次，但是下边只调用了一次，所以会报出异常 EXPECT_CALL(mockFoo, getPosition())
    .Times(2)
    .WillRepeatedly(Return(n++));

    int val = mockFoo.getPosition(); //100
    cout << "Returned Value: " << val << endl; //getPosition指定了调用两次，这里只调用了一次，所以运行结果显示出错 return EXIT_SUCCESS;
}